if(NOT KMPKG_CMAKE_SYSTEM_NAME)
    kmpkg_check_linkage(ONLY_STATIC_LIBRARY ONLY_STATIC_CRT)
endif()

kmpkg_from_gitee(
    OUT_SOURCE_PATH SOURCE_PATH
    REPO kumo-pub/sentencepiece
    REF "v${VERSION}"
    SHA512 4713c215335e6a630e16790d0356193b2ff8f47572fa47d2d2d037d666894a261b757da91bca9ecb103fe831fe5e6362d39c8f12d3e1c81a398c09a6f00cc517
    HEAD_REF master
)

kmpkg_cmake_configure(
    SOURCE_PATH "${SOURCE_PATH}"
    OPTIONS
        -DSPM_ENABLE_SHARED=OFF
        -DSPM_USE_BUILTIN_PROTOBUF=ON
        -DSPM_USE_EXTERNAL_ABSL=OFF
)

kmpkg_cmake_install()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

kmpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

kmpkg_copy_tools(TOOL_NAMES spm_decode spm_encode spm_export_vocab spm_normalize spm_train AUTO_CLEAN)

kmpkg_copy_pdbs()

kmpkg_fixup_pkgconfig()
